/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.compose.integration.hero.jetsnack.implementation

import androidx.compose.runtime.Immutable

@Immutable
data class SnackCollection(
    val id: Long,
    val name: String,
    val snacks: List<Snack>,
    val type: CollectionType = CollectionType.Normal,
)

enum class CollectionType {
    Normal,
    Highlight,
}

/** A fake repo */
object SnackRepo {
    fun getSnacks(): List<SnackCollection> = snackCollections

    fun getSnack(snackId: Long) = snacks.find { it.id == snackId }!!

    fun getRelated(@Suppress("UNUSED_PARAMETER") snackId: Long) = related

    fun getInspiredByCart() = inspiredByCart

    fun getCart() = cart
}

/** Static data */
private val tastyTreats =
    SnackCollection(
        id = 1L,
        name = "Android's picks",
        type = CollectionType.Highlight,
        snacks = snacks.subList(0, 13),
    )

private val popular =
    SnackCollection(id = 2L, name = "Popular on Jetsnack", snacks = snacks.subList(14, 19))

private val wfhFavs = tastyTreats.copy(id = 3L, name = "WFH favourites")

private val newlyAdded = popular.copy(id = 4L, name = "Newly Added")

private val exclusive = tastyTreats.copy(id = 5L, name = "Only on Jetsnack")

private val also = tastyTreats.copy(id = 6L, name = "Customers also bought")

private val inspiredByCart = tastyTreats.copy(id = 7L, name = "Inspired by your cart")

private val offers = tastyTreats.copy(id = 8L, name = "Latest offers")
private val bestSelling = popular.copy(id = 9L, name = "Best selling")
private val preOrder = tastyTreats.copy(id = 10L, name = "Available for pre-order")

private val snackCollections =
    listOf(
        tastyTreats,
        popular,
        wfhFavs,
        newlyAdded,
        exclusive,
        also,
        inspiredByCart,
        offers,
        bestSelling,
        preOrder,
    )

private val related = listOf(also, popular)

private val cart = listOf(OrderLine(snacks[4], 2), OrderLine(snacks[6], 3), OrderLine(snacks[8], 1))

@Immutable data class OrderLine(val snack: Snack, val count: Int)
